<html><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>产康预约</title>

  <#assign base=request.contextPath  />
  	<base id="basePath" href="${base}">

  	<base id="basePath" href="${base}">
  	<link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
  	<link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
  	<script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
  	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
  	<script type="text/javascript" src="${base}/js/zhang.js"></script>
  	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
  	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>


  	<script type="text/javascript" src="${base}/js/zhang.js"></script>

  <link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
  <link rel="stylesheet" type="text/css" href="${base}/js/layui/css/layui.css"/>
 <style type="text/css">

  </style>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>产康预约</legend>
</fieldset>
		<table class="layui-hide" id="table_baby" lay-filter="user"></table>
		<script type="text/html" id="barDemo">

		     {{#  if(d.appointment ==1){ }}
             <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"  href="javascript:void(0)"  onclick="Reservable('{{d.id}}')">不可预约</a>
                      {{#  } else { }}
             <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail" href="javascript:void(0)"  onclick="Reservable2('{{d.id}}')">可预约 </a>

             {{#  } }}
		</script>
    </div>
  </div>
<script src="${base}/js/layui/layui.js" charset="utf-8"></script>
<script src="${base}/js/jquery.min.js"></script>
<script>

layui.use('table', function(){
  var table = layui.table;
  table.render({
    elem: '#table_baby'
    ,url: '${base}/production/selectProduction'//数据接口
    ,cols: [[
    //function()是格式化id,本应该id是long类型,现在格式化成int类型
      {field:'id',templet:function(val){
                                return val.LAY_INDEX
                             }, title: 'ID',align: 'center'}
      ,{field:'project', title: '产康项目',align: 'center'}
      ,{field:'pice', title: '价格',align: 'center'}
      ,{field:'appointment',templet:function(val){
                              if(val.appointment=="1"){
                              return "可预约";
                              }else{
                              return "不可预约";
                              }
                            }, title: '状态',align: 'center'}
      ,{field: 'right',align: 'center', toolbar: '#barDemo', title: '操作'}
    ]]
    ,id: 'testReload'
   ,page: {
              layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
              ,theme: '#0092EF'
              ,limit:20
           }
       ,height: 500
  });





});


//那个房间添加那个项目
function onSubmit(){
var id = $("#id").val();
var project = $("#project").val();
var price = $("#price").val();
var appointment = $("#appointment").val();
    $.ajax({
               type:"POST",
               url:"${base}/production/insertProduction",
               data:{"id":id,"project":project,"pice":price,"appointment":appointment},
               success:function(data){
                   var table = layui.table;
                                //表刷新方法
                               table.reload('testReload', {
                               url: '${base}/production/selectProduction'
                               ,where: {}, //设定异步数据接口的额外参数
                               //height: 300
                               });
                               $(".tk2").hide(200)
                           }

           });
}

//修改状态 可预约变成不可预约
function Reservable(id){

$.ajax({
        type:"POST",
        url:"${base}/production/update",
        data:{"id":id},
        async:false,
        success:function(data){
        layer.msg("修改成功")
    var table = layui.table;
                         //表刷新方法
                        table.reload('testReload', {
                        url: '${base}/production/selectProduction'
                        ,where: {}, //设定异步数据接口的额外参数
                        //height: 300
                        });
               $(".tk2").hide(200)
             }
});
}

//修改 不可预约修改可预约
function Reservable2(id){
$.ajax({
        type:"POST",
        url:"${base}/production/update2",
        data:{"id":id},
        async:false,
        success:function(data){
            layer.msg("修改成功")
    var table = layui.table;
                         //表刷新方法
                        table.reload('testReload', {
                        url: '${base}/production/selectProduction'
                        ,where: {}, //设定异步数据接口的额外参数
                        //height: 300
                        });
               $(".tk2").hide(200)
             }
});
}



</script>
</body>
</html>